<?php
# header of each page
function head($title='', $meta_description='', $meta_keywords='', $active='') {
header("Content-type: text/html; charset=UTF-8");
?>
<!DOCTYPE html>
<html>
<head>
<title><?=$title?></title>
<meta name="description" content="<?=$meta_description?>" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="shortcut icon" href="favicon.ico">

<link href='http://fonts.googleapis.com/css?family=Comfortaa:700,300&subset=latin,cyrillic' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="<?=HTML_BASE?>css/reset.css">
<link rel="stylesheet" type="text/css" href="<?=HTML_BASE?>css/style.css">
<script src="<?=HTML_BASE?>js/modernizr.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
<script src="<?=HTML_BASE?>js/jquery.carouFredSel.js" type="text/javascript"></script>
<!--[if IE]>
	<link rel="stylesheet" type="text/css" href="css/all-ie-only.css" />
<![endif]-->
<!--[if lt IE 8]>
	<link rel="stylesheet" type="text/css" href="css/ie7-and-down.css" />
<![endif]-->
<script type="text/javascript" src="<?=HTML_BASE?>fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
<script type="text/javascript" src="<?=HTML_BASE?>fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<link rel="stylesheet" type="text/css" href="<?=HTML_BASE?>fancybox/jquery.fancybox-1.3.4.css" media="screen" />


</head>

<body>
    
  
<?php	
}
function menue()
{
?>
    <div id="wrap">
	
    <div id="top">
	
		<div id="icons">
			<a id="logo" href="<?=HTML_BASE?>"></a>
			<a class="print" href="#"><span class="txt">Печат</span><span class="pic"></span></a>
			<a class="pvc" href="#"><span class="txt">Изделия от Плексиглас</span><span class="pic"></span></a>
			<a class="shirt" href="#"><span class="txt">Тениски</span><span class="pic"></span></a>
			<a class="folio" href="#"><span class="txt">Интериорни решения</span><span class="pic"></span></a>
		</div>
		
		<h3>Хартиени торби</h3>
		
		<div id="menu">
			<a class="info" href="http://kips-bg.com" title="Част от K&amp;P's"></a>
			<a id="inq-form-up" href="#inquiry-form">Запитване</a>
			<a href="<?=HTML_BASE?>products/">Каталог</a>
		</div>
		
	</div>

<?php
}
# footer of each page
function foot($sef_url = '') {
	?>
 
 <div id="footer">
		
		<div class="footerbox">
			<h5>Офис</h5>
			<span class="address">ул Акад. Г. Бончев 4</span>
			<span class="phone">02 971 94 88, 02 971 40 26</span>
			<span class="email"><a href="mailto:info@kips-bg.com" target="_blank">info@kips-bg.com</a></span>
			<span class="fb"><a href="#" target="_blank">@kips</a></span>
		</div>
		
		<div class="footerbox">
			<h5>Пенка Влахова</h5>
			<span class="id">мениджър реклама</span>
			<span class="phone">0888 34 35 39</span>
			<span class="email"><a href="mailto:pepi@kips-bg.com" target="_blank">pepi@kips-bg.com</a></span>
			<span class="fb"><a href="#" target="_blank">@penka.vlahova</a></span>
		</div>
		
		<div class="footerbox">
			<h5>Елица Стоянова </h5>
			<span class="id">акаунт мениджър</span>
			<span class="phone">тел.: 0878 747 005</span>
			<span class="email"><a href="mailto:office@kips-bg.com" target="_blank">office@kips-bg.com</a></span>
			<span class="fb"><a href="#" target="_blank">@kips</a></span>
		</div>
		
	</div>
    
</div>

<div style="display:none;">
    <div id="inquiry-form" >
    <h3>Запитване</h3><br>
    
    <script type="text/javascript" src="<?=HTML_BASE?>js/inquiry.js"></script>
    <div id="formа">
	
	<form>
	
	<h5>Продукт</h5>
	
    <select id="product">
                <option value=""> - Модел -</option>
                <?php
                
						$sql_products = "SELECT
						  c.catalog_id,
						  c.sef_url,
						  
						  d.title
						  
					  FROM
						  catalog AS c,
						  catalog_description AS d
					  WHERE
					  
						  c.catalog_id = d.catalog_id
						  
						  AND
						  c.published
						  AND
						  
						  d.lang_id = '1'
						  
						  ORDER BY c.order_number DESC
						";
						$result_products = query($sql_products);
						while ($row_products = mysql_fetch_object($result_products)) { 
				
				
				?>
                <option value="<?=$row_products->title?>" <?php if($row_products->sef_url == $sef_url) echo 'selected="selected"';?> ><?=$row_products->title?></option>
               <?php }?>
    </select><br>
    
    
    <select id="pepar">
                <option value=""> - Хартия - </option>
                <option value="крафт">Крафт</option>
                <option value="хром с ламинат">Хром с ламинат</option>
                <option value="ефектни хартии">Ефектни хартии</option>
                
    </select><br>
    
    <select id="color">
                <option value=""> - Цвят - </option>
                <option value="Pantone">Pantone</option>
                <option value="CMYK">CMYK</option>
                
    </select><br>
    
     <input id="inquiry-size"  class="inputbox" name="size" type="text" value="Размер (височина - широчина - фалта)" 
    onblur="if(this.value=='') this.value='Размер (височина - широчина - фалта)';" 
	onfocus="if(this.value=='Размер (височина - широчина - фалта)') this.value='';"><br>
    
     <input id="inquiry-amount"  class="inputbox" name="amount" type="text" value="Количество (бр.)" 
    onblur="if(this.value=='') this.value='Количество (бр.)';" 
	onfocus="if(this.value=='Количество (бр.)') this.value='';"><br>
    
    
	
	<textarea id="inquiry-inquiry"  class="inputbox" name="inquiry" type="text" rows="3" onblur="if(this.value=='') this.value='Допълнителна информация';" 
	onfocus="if(this.value=='Допълнителна информация') this.value='';">Допълнителна информация</textarea><br>
	
	<h5>Лице за контакт</h5>
   
    <input id="inquiry-name"  class="inputbox" name="name" type="text" value="Име" 
    onblur="if(this.value=='') this.value='Име';" 
	onfocus="if(this.value=='Име') this.value='';"><br>

    
    <input id="inquiry-phone"  class="inputbox" name="phone" type="text" value="Телефон" onblur="if(this.value=='') this.value='Телефон';" 
	onfocus="if(this.value=='Телефон') this.value='';"><br>

    <input id="inquiry-email"  class="inputbox" name="email" type="text" value="E-mail" onblur="if(this.value=='') this.value='E-mail';" 
	onfocus="if(this.value=='E-mail') this.value='';"><br>
    
    <input class="button" type="button" value="Изпрати" onClick="return send_inquiry();" />
    
	</form>	
    </div>		
	</div>
</div>

<script>
$(document).ready(function() {
$("#inq-form-up").fancybox({
	'scrolling'		: 'no',
	'titleShow'		: false
});
}); 

</script>
        
<?php
}

# a redirecting function that adds the session ID if cookies are disabled and stops the execution of the script
function redirect($location) {
	if (!$location) error("Missing arguments.");

	$a = parse_url($location);
	if (!isset($a['query'])) {
		$a['query'] = '';
	}
	
	$session_delimiter = ($a['query'])?'&':'?';
	header("Location: $location".addsession($session_delimiter));
	exit;
}

# adding the session_id when cookies are disabled
function addsession($symbol="?") {
	return (!isset($_COOKIE[session_name()])&&session_id())?$symbol.session_name()."=".session_id():"";
}

function escape($string,$encoding=false) {
  return mysql_real_escape_string( (($encoding)?encoding($string):$string) );
}

function encoding($string) {
  return iconv('ISO-8859-1', 'UTF-8', $string);
}

function sth($string) {
  return htmlspecialchars(stripslashes($string));
}

# checks whether an email is valid or not
function checkEmail($email) {
	return preg_match("/^[A-z0-9\.\-]+@(?:[A-z0-9\-]+\.)+[A-z0-9]{1,6}$/", $email);
}

# Cut a text to specified chracters length
function text_format($text, $length) {
	$str = '';
	$text_length = mb_strlen($text, "UTF-8");
	 
	if ($text_length < $length) {
		$str = $text;		
	} else {
		$position_end = strpos($text, ' ', $length);
		$str = substr($text, 0, ($position_end)?$position_end:$text_length);
	}
	
	return $str;
}

function text_format_blog($text, $length) {
	$str = '';
	$text_length = mb_strlen($text, "UTF-8");
	 
	if ($text_length < $length) {
		$str = $text;		
	} else {
		$position_end = strpos($text, '<hr />', $length);
		$str = substr($text, 0, ($position_end)?$position_end:$text_length);
	}
	
	return $str;
}


# general error function
function error($s="An error occured.") {
  if (!headers_sent()) {
    head("Error");
    echo "<table cellpadding=4 width=".SITE_WIDTH." align=center border=0><tr><td align=center class=title>$s</td></tr></table>";
    foot();
  }
  else
    echo $s;
  exit;
}

# debug function for dumping a variable value
function pp($var, $stop=false) {
  echo "<pre>";
  print_r($var);
  echo "</pre>";
  if ($stop) exit;
}

# Generate numbers
function generateNumber () {

  # start with a blank number
  $number = "";

  # define possible characters
  $possible = "0123456789"; 

  # pick a random character from the possible ones
  $number = substr($possible, mt_rand(0, strlen($possible)-1), 1);

  # done!
  return $number;

}



?>